import { Navigate, type RouteObject } from 'react-router-dom'
import { AppstoreOutlined } from '@ant-design/icons';
import Layout from '@/layouts'
import Users from '@/views/users'
import Login from '@/views/login'
import Home from '@/views/home'
import i18n from '@/locales'

const t = i18n.t

export type RouteMenuItem = RouteObject & {
  path: string
  title: string
  icon?: React.ReactNode
  auth?: bigint
  children?: RouteMenuItem[]|undefined
}

export const menuRoute = (): RouteMenuItem[]=>[
  {
    path: 'home',
    title: t('route.home'),
    icon: <AppstoreOutlined />,
    element: <Home />,
  },
  {
    path: 'user',
    title: t('route.user'),
    icon: <AppstoreOutlined />,
    element: <Users />,
    children: [
      {
        path: 'test1',
        title: "测试1",
        element: <Users />,
      },
      {
        path: 'test2',
        title: "测试2",
        element: <Users />,
      }
    ]
  }
]

const routes: RouteObject[] = [
  {
    path: '/',
    element: <Navigate to="/home" replace />,
  },
  {
    path: '/',
    element: <Layout />,
    children: menuRoute(),
    action:()=>{
      return false
    }
  },
  {
    path: '/login',
    element: <Login />,
  },
  {
    path: '*',
    element: <div>404</div>
  }
]

export default routes